x=0:20;
a2=10;r=a2*0.01;
u=zeros(21,25);;%预设矩阵以存放求得的解%初始条件%求解及作图
u(10:11,1)=1;%初始条件
for j=1:25%求解及作图
    u(2:20,j+1)=(1-2*r)*u(2:20,j)+r*( u(1:19,j)+u(3:21,j));
    plot(x,u(:,j));axis([0 21 0 1]);pause(0.1)
end
meshz(u)